package shopping.feign.call.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import shopping.feign.call.feignclient.ShoppingFeignClient;

@RestController
public class OrderController {
  
  private static final Logger log = LoggerFactory.getLogger(OrderController.class);
  @Autowired
  private ShoppingFeignClient shoppingFeignClient;
  
  @GetMapping("/order/create/{productId}")
  public String createOrder(@PathVariable String productId) {
    String reduce = shoppingFeignClient.reduce(productId);
    
    log.info("减库存成功: {}", reduce);
    return reduce;
  }
}
